package com.pattern.creational_pattern.builder_pattern;

/**
 * @Description  DIRECTOR: assembling all parts to build the new meal.
 * @Author Ping
 * @Date 2022/3/20 22:49
 **/
public class NewWaiter {
    private MealNewBuilder mealBuilder ;

    public NewWaiter(MealNewBuilder mealBuilder) {
        this.mealBuilder = mealBuilder;
    }

    public void setMealBuilder(MealNewBuilder mealBuilder) {
        this.mealBuilder = mealBuilder;
    }

    /**
     * assembling/constructing the meal from parts
     * @return
     */
    public Meal build() {
        // the PROCESS for assembling the meal
        return  mealBuilder.buildFood()
                             .buildDrink()
                               .buildMeal() ;

    }



    public static void main(String args[]) {
        // client to get a meal from waiter
//        NewWaiter waiter = new NewWaiter(new BeefBurgBuilder()) ;
//        Meal beefMeal = waiter.build() ;
//        System.out.println(beefMeal);
//        waiter.setMealBuilder(new ChickenBurgBuilder());
//        Meal chickenMeal = waiter.build() ;
//        System.out.println(chickenMeal);

    }
}
